import 'dart:convert';

import 'package:flutter_base/generated/json/base/json_field.dart';
import 'package:flutter_base/generated/json/knowlege_entity.g.dart';

export 'package:flutter_base/generated/json/knowlege_entity.g.dart';

//知识体系列表
class KnowledgeListData {
  List<KnowlegeData>? knowledgeList;

  KnowledgeListData.fromJson(dynamic json) {
    if (json is List) {
      knowledgeList = [];
      for (var element in json) {
        knowledgeList?.add(KnowlegeData.fromJson(element));
      }
    }
  }
}

@JsonSerializable()
class KnowlegeData {
  late List<dynamic> articleList = [];
  late String author = '';
  late List<KnowlegeDataChildren>? children = [];
  late int courseId = 0;
  late String cover = '';
  late String desc = '';
  late int id = 0;
  late String lisense = '';
  late String lisenseLink = '';
  late String name = '';
  late int order = 0;
  late int parentChapterId = 0;
  late int type = 0;
  late bool userControlSetTop = false;
  late int visible = 0;

  KnowlegeData();

  factory KnowlegeData.fromJson(Map<String, dynamic> json) =>
      $KnowlegeDataFromJson(json);

  Map<String, dynamic> toJson() => $KnowlegeDataToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class KnowlegeDataChildren {
  late List<dynamic> articleList = [];
  late String author = '';
  late List<dynamic> children = [];
  late int courseId = 0;
  late String cover = '';
  late String desc = '';
  late int id = 0;
  late String lisense = '';
  late String lisenseLink = '';
  late String name = '';
  late int order = 0;
  late int parentChapterId = 0;
  late int type = 0;
  late bool userControlSetTop = false;
  late int visible = 0;

  KnowlegeDataChildren();

  factory KnowlegeDataChildren.fromJson(Map<String, dynamic> json) =>
      $KnowlegeDataChildrenFromJson(json);

  Map<String, dynamic> toJson() => $KnowlegeDataChildrenToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
